package Day2025_02_25;

public class LeetCode495 {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int n = timeSeries.length;
        int ret = 0, sum = 0;
        for (int i = 0; i < n - 1; i++) {
            int tmp = timeSeries[i + 1] - timeSeries[i];
            if (tmp < duration) ret += duration - tmp;
        }
        sum += n *duration - ret;
        return sum;
    }
}
